package common.store.web.controller;

import common.store.common.util.C3p0Pool;
import common.store.common.util.MD5;
import common.store.web.bean.Order;
import common.store.web.bean.User;
import common.store.web.service.OrderService;
import common.store.web.service.impl.OrderServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.UUID;

@WebServlet("/order")
public class orderServlet extends HttpServlet {
    OrderService orderService;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req , resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        User user= (User)req.getSession().getAttribute("user");
        Order order=new Order();
        order.setUid(user.getUid());
        order.setName(req.getParameter("name"));
        order.setPhone(req.getParameter("phone"));
        order.setAddress(req.getParameter("address"));
        orderService=new OrderServiceImpl();
        Integer row=orderService.updateOrder(order);
        req.getRequestDispatcher("/orderList").forward(req,resp);
    }
}
